<include file="Public/header" />
<title>我的桌面</title>
</head>
<body>
<div class="page-container">
    <div >
        <div id="DataTables_Table_0_wrapper" class="dataTables_wrapper no-footer">
            <table class="table table-border table-bordered table-bg table-hover table-sort dataTable no-footer" id="DataTables_Table_0" role="grid" aria-describedby="DataTables_Table_0_info">
                <thead>
                <tr class="text-c" role="row">
                    <th width="80" class="sorting_desc" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1">ID</th>
					 <th width="200">采购单编号</th>
                    <th width="200">商品名称</th>
					<th width="60">商品编码</th>
					<th width="60">销售单价</th>
					<th width="60">损耗单价</th>
					<th width="60">损耗数量</th>
                    <th width="60">数量</th>
                    <th width="60">规格</th>
                    <th width="60">原产国</th>
                </tr>
                </thead>
                <tbody>
                <foreach name="list" item="data">
                    <tr class="text-c odd" role="row">
                        <td><{$data.id}></td>
						<td><{$detail.order_no}></td>
                        <td><{$data.goods_name}></td>
						<td class="td-status"><{$data.goods_sn}></td>
						<td><{$data.goods_price}></td>
						<td><input class="input-text" attr_id="<{$data.id}>" style="width:50px" type="text" value="<{$data.wastage_goods_price}>" name="wastage_goods_price"></td>
						<td><input class="input-text" attr_id="<{$data.id}>" style="width:50px" type="text" value="<{$data.wastage_goods_nums}>" name="wastage_goods_nums"></td>
                        <td><{$data.goods_nums}></td>
                        <td><{$data.spec}></td>
                        <td>
							<select name="country_code" class="form-control selects" 
						 <volist name="country" id="vcc">
							<if condition="$vcc['country_code'] == $data['source']">disabled="disabled"  style="width:130px;background:#ccc;"
							</if>
						 </volist>
					 >
                         <option value="">请选择</option>
                         <volist name="country" id="vcc">
                             <option value="<{$vcc.country_code}>" <if condition="$vcc['country_code'] == $data['source']">selected</if>><{$vcc.country_name}></option>
                         </volist>
                     </select>
						</td>
                    </tr>
                </foreach>
                </tbody>
            </table>
            <div style="margin-top: 12px;" class="Huialert Huialert-info"><i class="icon-remove"></i>确定修改，保存数据</div>
            <div style="margin-top: 32px;">
				<a href="javascript:;" onclick="confirm_edit()" class="btn btn-primary radius"><i class="Hui-iconfont"></i>确定修改</a>
            </div>
        </div>
    </div>
    <include file="Public/footer_js" />
    <script>
		function confirm_edit(){
			var option = $('input[name=wastage_goods_price]');
			var options = $('input[name=wastage_goods_nums]');
			var ids= [];
			var prices= [];
			var nums= [];
            for(i=0;i<option.length;i++){
				ids.push(option.eq(i).attr('attr_id'));
				prices.push(option.eq(i).val());
				nums.push(options.eq(i).val());
			}
			//订单检查，是否已生成波次单
			$.ajax({
				type: 'POST',
				data: {ids:ids,prices:prices,nums:nums},
				url: "<{:U('confirm_edit_wastage')}>",
				success:function(data){
					if(data.status==1){	//检查通过，跳转生成波次单页面
						layer.msg(data.message,function(){
							window.location.reload();
						});
						
					}else{				//检查未通过，刷新页面
						layer.msg(data.message);
					}
					return false;
				}
			})
		}
    </script>
</body>
</html>